package biznussoft.fieldservice360;

import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.FragmentTransaction;
import biznussoft.fieldservice360.fragments.ContactDetailsFragment;
import biznussoft.fieldservice360.listeners.GlobalListener;


public class ContactsActivity extends BaseActivity implements GlobalListener {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_contact);
	}
/*
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.inventory, menu);
		return true;
	}*/
	
	/*@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// TODO Auto-generated method stub
		  MenuItem actionItem = menu.add("Logout");                 
	        MenuItemCompat.setShowAsAction(actionItem,MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT);
	        actionItem.setIcon(R.drawable.logout); 
		return super.onCreateOptionsMenu(menu);
	}
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// TODO Auto-generated method stub
		 Log.i("NCS","item.getItemId()  :"+item.getTitle()+": "+item.getOrder());
		 if(item.getTitle().equals("Logout")){
			 SalesforceSDKManager.getInstance().logout(this);}
		return super.onOptionsItemSelected(item);
	}*/

	@Override
	public void onCategoryClicked(int position) {
		// TODO Auto-generated method stub

	}

	@Override
	public void onNewContact(String[] args) {
		// TODO Auto-generated method stub

	}

	@Override
	public void onGetContacts(final int position, final String category) {

		ContactDetailsFragment newFragment = new ContactDetailsFragment();
		FragmentTransaction transaction = getSupportFragmentManager()
				.beginTransaction();
		transaction.replace(R.id.contactViewer, newFragment);
		transaction.addToBackStack(null);
		transaction.commit();

		new Handler().postDelayed(new Runnable() {
			@Override
			public void run() {

				ContactDetailsFragment contactFragment = (ContactDetailsFragment) getSupportFragmentManager()
						.findFragmentById(R.id.contactViewer);
				contactFragment.showContacts(position, category);
			}
		}, 1000);

	}

	@Override
	public void getSignature(String base64) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void displayFields(int position, String category) {
		// TODO Auto-generated method stub
		
	}

}
